import { urlEncrypt } from './urlEncrypt'

interface printParams {
  fileSource: string
  localFilePathList: string[]
  fileName: string
  loadingHeader: any
  loadingParam: any
  loadingUrl: string
  requestMethodName: string
}
const printFn = (params: printParams) => {
  const token = window.sessionStorage.getItem('token')
  const store = JSON.parse(window.sessionStorage.getItem('main') as string)
  const ryid = store?.userInfo?.ryid
  const param = {
    ...params,
    loadingHeader: {
      ...params.loadingHeader,
      'gd-token': token || '',
      userId: ryid || '',
    },
  }
  const query = urlEncrypt.Encrypt(JSON.stringify(param))
  window.printDialogRef.value?.openDialog(`${window.PRINTIP}/?${query}`)
}

export default printFn
